/*
  @author dmj1161859184@126.com 2018-08-05 02:49
  @version 1.0
  @since 1.0
*/

//Reference: https://juejin.im/post/5951ba9f6fb9a06bbd6f5a12
//var class2type = {};
let class2type = {};

// 生成class2type映射
"Boolean Number String Function Array Date RegExp Object Error Null Undefined".split(" ").map(function(item, index) {
    class2type["[object " + item + "]"] = item.toLowerCase();
});

function type(obj) {
    if (obj == null) {
        return obj + "";
    }
    return typeof obj === "object" || typeof obj === "function" ?
        class2type[Object.prototype.toString.call(obj)] || "object" :
        typeof obj;
}